<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc_min.jsp"></jsp:include>
<meta http-equiv="X-UA-Compatible" content="edge" />
<title>提现审核查询页面</title>
<link rel="stylesheet" href="${ctx}/css/page.css"/>
<link rel="stylesheet" href="${ctx}/css/iconfont.css"/>
<script type="text/javascript">
	$(function(){
		$(".listArg").click(function(){
			$(".listArg").css({
				"background": "#f1f1f1",
				"color": "black"
			});
			$(this).css({
				"background": "#28aaf0",
				"color": "#FFFFFF"
			});
			/* var conStatus=$(this).find("span").attr('id');
			getAjax(conStatus); */
		});
		//封装函数  实现查询订单功能
		getAjax("","");
		//点击查询
		$("#query").click(function(){
			var payOrderNumber=$("#_orderNumber").val();
			var buyer=$("#buyer").val();
			var startDate=$("#_startTime").val();
			var endDate=$("#_endTime").val();
			getAjax("","");
		});
	});
    //全局变量 总页数
    var pageNum = 1;
    function getAjax(status){
        layer.load();
        var pageSize = 20;
        var payOrderNumber=$("#_orderNumber").val();
        var buyer=$("#buyer").val();
        var startDate=$("#_startTime").val();
        var endDate=$("#_endTime").val();
        $.ajax({
            type:"get",
            url:"${ctx}/tradeList/checkPage?tradeType=2&rand="+Math.random()+"&payOrderNumber="+payOrderNumber
            +"&buyer="+buyer+"&startDate="+startDate+"&endDate="+endDate+"&status="+status+"&page="
            +pageNum+"&rows="+pageSize,
            async:true,
            success:function(data){
                layer.closeAll();
                $('table tbody').empty();
                var obj=data.rows;
                for(var i=0;i<obj.length;i++){
                    var id=obj[i].id;
                    var payOrderNumber=obj[i].payOrderNumber;//支付单号
                    var organizationName=obj[i].organizationName;//采购商
                    var createTime=obj[i].createTime//操作日期
                    var accountBalance=obj[i].accountBalance;//账户余额
                    var bankName=CommonConverter.toEmptyString(obj[i].bankName);//开户行
                    var bankUser=CommonConverter.toEmptyString(obj[i].bankUser);//户名
                    var bankCard=CommonConverter.toEmptyString(obj[i].bankCard);//卡号
                    var cost=CommonConverter.toEmptyString(obj[i].cost);//提现金额
                    var tradeType=CommonConverter.toTradeStr(obj[i].tradeType);//交易类型
                    var statusStr=CommonConverter.toWithdrawstr(obj[i].status);//状态
                    var operation='<i class="icon iconfont position" title="详情" onclick=detail("'+id+'")>&#xe62d;</i>';
                    if(obj[i].status == 0){
                        //operation='<svg class="icon position" onclick=check("'+id+'") aria-hidden="true"><use xlink:href="#icon-lwsh"></use></svg>'//審核
                        operation='<i class="icon iconfont position" title="审核" onclick=check("'+id+'")>&#xe604;</i>';
                    }else if(obj[i].status == 1){
                        operation='<span class="add_minus" onclick=pay("'+payOrderNumber+'") style="margin-right:19px;width:62px;height:22px">支付</span>';
                    };
                    tbody='<tr height="38" class="reBorder">'+
                            '<td width="219" align="center">支付单号：'+payOrderNumber+'</td>'+
                            '<td width="1081" colspan="6" align="right" style="color:#fdc473;cursor:pointer;">'+
                            operation+'</td>'+
                            '</tr>'+
                            '<tr height="90"><td width="219" align="center" style="color:black;">'+organizationName+'</td>'+
                            '<td width="173" align="center" style="color:black">'+createTime+'</td>'+
                            '<td width="180" align="center" style="color:#e47470">￥'+accountBalance+'</td>'+
                            '<td width="200"  style="color:black">'+
                            '<span style="margin-left:50px;">开户行：'+bankName+'</span><br/>'+
                            '<span style="margin-left:50px;">户名：'+bankUser+'</span><br/>'+
                            '<span style="margin-left:50px;">卡号：'+bankCard+'</span><br/>'+
                            '<span style="margin-left:50px;">提现金额：￥'+cost+'</span></td>'+
                            '<td width="238" align="center" style="color:black">'+tradeType+'</td>'+
                            '<td width="100" align="center" ><span style="padding-left:20px;color:#e47470">'+statusStr+'</span></td>'+
                            '</tr> ';
                    $("#tb").append(tbody);
                };
                //显示分页
                layui.use(['laypage', 'layer'], function(){
                    var laypage = layui.laypage;
                    laypage({
                        cont: 'pager'
                        ,pages:  Math.ceil(data.total/20) //得到总页数 //总页数
                        ,groups: 5 //连续显示分页数
                        ,skin: '#1E9FFF'
                        ,curr : pageNum
                        ,jump: function(obj,first){
                            if(!first){
                                pageNum = obj.curr;
                                getAjax(status);
                            }
                        }
                    });
                });
            }
        });
    };
	//查看
	function detail(id){
		layer.open({
			type: 2,
			title: ['审核','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.5,
			area: ['500px', '300px'],
			content: ['${ctx}/np/checkTXDetail/'+id, 'no']
		});
	};
	//审核
	function check(id,number){
		layer.open({
			type: 2,
			title: ['审核','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.5,
			area: ['500px', '400px'],
			content: ['${ctx}/np/checkPageTX/'+id, 'no'],
			end:function(){
				getAjax("");
			}
		});
	};
	//付款
	function pay(cashNo){
		//alert(cashNo);
		layer.open({
			type: 2,
			title: ['付款 提现单号:'+cashNo,'background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.3,
			yes: function(index, layero) {
				layer.close(index);
			},
			btn2: function(index, layero) {
				//取消的回调
			},
			area: ['600px', '600px'],  
			content: ['${ctx}/np/toPaymentPage/'+cashNo],  //iframe的url，no代表不显示滚动条
			success: function(layero, index){
				//  layer.full(index);
			},
			end:function(){
				getAjax("");
			}
		});
	};
</script>
</head>
<body>
<jsp:include page="../head.jsp"/>
<div class="content">
			<ul class="list">
					<li>
						支付单号：<input  id="_orderNumber" name="charterType" class="easyui-textbox"/>
					</li>
					<li>
						采购商：<input  id="buyer" name="charterType" class="easyui-textbox"/>
					</li>
					<li>
						操作日期 ：<input class="textbox" id="_startTime" onclick="new WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 120px" />
						至<input class="textbox" id="_endTime" onclick="new WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 120px" />
					</li>
					<!-- <li>
						状态：
						<select id="status" style="width: 83px;">
							<option value="">全部</option>
							<option value="-1">审核不通过</option>
							<option value="0">待审核</option>
							<option value="1">已充值</option>
						</select>
					</li> -->
					<li class="right">
						<button class='query' id="query">查询</button>
					</li>
				</ul>
				 <ul class="list conditionList">
		         	<li>状态：</li>
					<li  class="listArg allStatus" onclick="getAjax('')">
						<span/>全部</span>
					</li>
					<li class="listArg "  onclick="getAjax(-1)">
						<span >审核不通过</span>
					</li>
					<li class="listArg " onclick="getAjax(0)">
						<span>待审核</span>
					</li>
					<li class="listArg " onclick="getAjax(1)">
						<span>待支付</span>
					</li>
					<li class="listArg " onclick="getAjax(2)">
						<span >已付款</span>
					</li>
				</ul>
				<table class="conTable" >
					<thead>
						<tr height="38" >
							<td width="219" align="center">采购商</td>
							<td width="173" align="center">操作日期</td>
							<td width="233" align="center">账户余额</td>
							<td width="183" align="center">交易信息</td>
							<td width="238" align="center">类型</td>
							<td width="100" align="center"><span style="padding-left:20px;">状态</span></td>
						</tr>
					</thead>
					<tbody id="tb">
					</tbody>
			</table>
        <!-- 分页 -->
        <div id="pager" class="divBox"></div>
		</div>
<jsp:include page="../footer.jsp"/>
</body>
</html>